// 1437. 是否所有 1 都至少相隔 k 个元素


#include <vector>
using namespace std;

class Solution 
{
public:
    bool kLengthApart(vector<int>& nums, int k) 
    {
        for(int left = -1, right = 0; right < nums.size(); right++)
        {
            if(-1 == left && 1 == nums[right]) left = right;
            else if(-1 != left && 1 == nums[right])
            {
                if(right - left - 1 < k) return false;
                else left = right;
            } 
        }
        return true;
    }
};